use crate::hf::{CloseBox, OpenBox};

mod hf {
    // 公有 struct, 带公有字段
    pub struct OpenBox<T> {
        pub contents: T,
    }

    // 公有struct,带私有字段
    #[allow(dead_code)]
    pub struct CloseBox<T> {
        contents: T,
    }

    // 公有构造器
    impl<T> CloseBox<T> {
        pub fn new(contents: T) -> CloseBox<T> {
            CloseBox { contents: contents }
        }
    }
}

fn main() {
    println!("结构体可见性");

    let ob = OpenBox { contents: "abcde" };
    println!("公有字段可正常访问: {}", ob.contents);

    // 私有字段,不能直接访问
    // let cb =CloseBox{contents:""};

    // if this is intentional, prefix it with an underscore: `_cb`
    let _cb = CloseBox::new("bee");
    // println!("私有变量不可用: {}", cb.contents);
}
